package id.laskarmedia.opnvpn_flutter.util;

import android.text.TextUtils;

import id.laskarmedia.opnvpn_flutter.bean.ServerConfig;
import io.flutter.plugin.common.MethodCall;

public class BeanConvertUtil {

    public static ServerConfig converServerConfig(MethodCall call) {
        if(call == null){
            return null;
        }
        String country = call.argument("country");
        String flagUrl = call.argument("flagUrl");
        String ovpn = call.argument("ovpn");
        String ovpnUserName = call.argument("ovpnUserName");
        String ovpnUserPassword = call.argument("ovpnUserPassword");
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.setCountry(country);
        serverConfig.setOvpn(ovpn);
        serverConfig.setFlagUrl(flagUrl);
        serverConfig.setOvpnUserPassword(ovpnUserPassword);
        serverConfig.setOvpnUserName(ovpnUserName);
        if(ovpn == null || TextUtils.isEmpty(ovpn)){
            return null;
        }
        return serverConfig;
    }
}
